#include "Path.h"

namespace poly
{
	Path::Path() : rigidBody(0), pointOfApp(0, 0, 0), path(0)
	{
	}

	void Path::apply(float dt)
	{
		float3 pt = transformCoord( pointOfApp, rigidBody->world() );
		PolyLine::ClosestPointDesc closest = path->closestPoint( pt );
		rigidBody->displace( closest.point - pt );
		RigidBody world;
		world.invMass = 0;
		world.invLocalInertia = zero33();
		if( closest.type = closest.SEGMENT )
			rigidBody->resolveSlide( world, closest.point, closest.tangent );
		else
			rigidBody->resolveJoint( world, closest.point );
	}
}
